<template>
	<view>
		<mescroll-body ref="mescrollRef" @down="downCallback" @up="upCallback">
			<view class="list-wrap">
				<view class="list-box">
					<view class="list-item-box" v-for="(item,index) in result" :key="index">
						<view class="top">
							<text class="time">{{item.create_time}}</text>
							<text class="satus">{{item.order_status}}</text>
						</view>
						<view class="goods-box">
							<view class="goods-item clear" v-for="(value,j) in item.item" :key="j">

								<view class="goods-img">
									<image :src="value.thumb_image">
								</view>

								<view class="goods-info">
									<view class="t">
										<text>{{value.title}}</text>
										<text>￥{{value.price}}</text>
									</view>
									<view class="b">
										<text>{{value.spec}}</text>
										<text>× {{value.nums}}</text>
									</view>
								</view>

							</view>

						</view>
						<view class="order" :class="{addBorder:item.active==6}">
							<view class="total">
								共{{item.item.length}}件商品，总金额
								<view>￥<text>{{item.order_amount}}</text></view>
							</view>
						</view>
						<view class="botttom">
							<text class="pay" @click="$utils.navigateTo('fapiao/kaiju',{ id: item.order_id })">开票</text>

						</view>
					</view>

				</view>
			</view>
		</mescroll-body>
		<view style="height: 50px;width: 100%;">
			
		</view>
		<view class="botm">
			<view @click="$utils.navigateTo('fapiao/history')">开票历史</view>
			<view @click="$utils.navigateTo('fapiao/taitou')">抬头管理</view>
		</view>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
	import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
	export default {
		mixins: [MescrollMixin],
		components: {
			MescrollBody,
			MescrollUni
		},
		data() {
			return {
				result: []
			};
		},
		onLoad(options) {},
		onBackPress(e) {
			//this.$utils.switchTab('ucenter/index');
			this.$utils.navigateTo('ucenter/index');
			return true;
		},
		methods: {
			downCallback() {
				setTimeout(() => {
					this.mescroll.resetUpScroll();
				}, 1200);
			},
			upCallback(page) {
				this.$http.getUnfapiao({
					page: page.num
				}).then((result) => {
					this.mescroll.endByPage(result.data.list.length, result.data.total);
					if (result.status == 1) {
						if (page.num == 1) this.result = [];
						this.result = this.result.concat(result.data.list);
					} else if (result.status == -1) {
						this.mescroll.endErr();
					}
				}).catch(error => {
					this.mescroll.endErr();
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.botm {
		display: flex;
		position: fixed;
		bottom: 0;
		width: 100%;
	}
	.botm view{
		width: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		height: 50px;
		background-color: #78C0F9;
		color: #fff;
		border: 1px solid #ddd;
	
	}

	.placeholder-box {
		width: 100%;
		height: 100rpx;
	}

	.addBorder {
		border-top: 2rpx solid #eee;
	}

	.menu {
		background-color: #b91922;
		height: 100rpx;
		line-height: 100rpx;
		position: fixed;
		width: 100%;
		top: 0rpx;
		font-size: 30rpx;
		z-index: 999999;

		.menu-wrap {
			display: flex;
			flex-wrap: nowrap;
			flex-direction: row;

			text {
				flex: 1;
				text-align: center;
				position: relative;
				color: #fff;
			}

			.active {
				color: #fff000;
			}
		}
	}

	.list-wrap {
		margin-top: 20rpx;
	}

	.list-box {
		display: flex;
		flex-direction: column;
		flex-wrap: wrap;

		.list-item-box {
			width: 95%;
			margin: 20rpx 2.5%;
			background-color: #fff;
			border-radius: 12rpx;

			.top {
				height: 90rpx;
				line-height: 90rpx;
				font-size: 30rpx;
				border-bottom: 2rpx solid #eee;

				.order-type {
					font-size: 28rpx;
					margin-right: 10rpx;
					color: #666;
				}

				text:first-child {
					float: left;
					padding-left: 20rpx;
				}

				text:last-child {
					font-size: 28rpx;
					float: right;
					padding-right: 20rpx;
				}
			}

			.goods-box {
				padding: 0 20rpx;

				.goods-item {
					padding-top: 20rpx;

					.goods-img {
						width: 154rpx;
						height: 154rpx;
						display: inline-block;
						float: left;

						image {
							width: 100%;
							height: 100%;
						}
					}

					.goods-info {
						display: inline-block;
						width: 72%;
						font-size: 28rpx;
						float: right;

						.t {
							width: 100%;
							height: 90rpx;

							text:first-child {
								float: left;
								display: -webkit-box;
								overflow: hidden;
								-webkit-line-clamp: 2;
								-webkit-box-orient: vertical;
								width: 70%;
							}

							text:last-child {
								width: 30%;
								float: right;
								text-align: right;
							}
						}

						.b {
							width: 100%;
							height: 80rpx;
							font-size: 26rpx;

							text:first-child {
								float: left;
								color: #999;
							}

							text:last-child {
								float: right;
								color: #666;
							}
						}
					}
				}
			}

			.order {
				width: 100%;
				height: 90rpx;
				line-height: 90rpx;
				border-bottom: 2rpx solid #eee;

				.total {
					height: 90rpx;
					line-height: 90rpx;
					text-align: right;
					font-size: 28rpx;
					padding-right: 20rpx;

					view {
						display: inline-block;
						color: red;

						text {
							font-style: normal;
							font-size: 32rpx;
						}
					}
				}
			}

			.botttom {
				width: 100%;
				height: 110rpx;
				line-height: 110rpx;
				text-align: right;

				text {
					font-size: 28rpx;
					text-align: center;
					border-radius: 30rpx;
					background-color: #fff;
					padding: 16rpx 30rpx;
					margin-right: 20rpx;
				}

				text.cancel {
					color: #333;
					border: 2rpx solid #ddd;
				}

				text.pay {
					background-color: #78C0F9;
					color: #fff;
				}
			}
		}
	}
</style>